package com.hsav.kcxb.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.hsav.kcxb.adapter.common.MyListBaseAdapter;
import com.hsav.kcxb.adapter.manager.CollectionManager;
import com.hsav.kcxb.bean.CollectionBean;

import java.util.ArrayList;
import java.util.List;

public class CollectionActivity extends BaseActivity {

    private ListView mListView;
    private ArrayList<CollectionBean> mCollectionBeanList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collection);
        initView();
    }

    private void initView() {
        TextView titleTx = (TextView) findViewById(R.id.tv_top_title);
        ImageView backImg = (ImageView) findViewById(R.id.iv_top_back);
        titleTx.setText("我的收藏");
        backImg.setVisibility(View.VISIBLE);

        mListView = (ListView) findViewById(R.id.listview_collection);
        initData();
        CollectionManager collectionManager = new CollectionManager(mCollectionBeanList, R.layout.item_collection_view);
        MyListBaseAdapter myListBaseAdapter = new MyListBaseAdapter(this, collectionManager);
        mListView.setAdapter(myListBaseAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            }
        });

        mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });
    }

    private void initData() {
        mCollectionBeanList = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            CollectionBean collectionBean = new CollectionBean("zhao" + i, "龙之谷" + i, "周杰伦" + i);
            mCollectionBeanList.add(collectionBean);
        }
    }
}
